package com.wash.shoes.request;

import com.ruoyi.common.core.domain.model.BaseModel;
import lombok.Data;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

@Data
public class DyBookResultRecord extends BaseModel implements Delayed {
    private final long delayTime; // 延迟时间，单位为毫秒

    /**
     * 重试次数
     */
    private int retryCount;
    /**
     * 订单id
     */
    private String orderId;
    @Override
    public long getDelay(TimeUnit unit) {
        long diff = delayTime - System.currentTimeMillis();
        return unit.convert(diff, TimeUnit.MILLISECONDS); // 返回剩余延迟时间
    }

    @Override
    public int compareTo(Delayed o) {
        DyBookResultRecord that = (DyBookResultRecord) o;
        long diff = this.delayTime - that.delayTime;
        return (diff == 0) ? 0 : ((diff < 0) ? -1 : 1); // 根据延迟时间排序
    }
}
